#include <stdio.h>
#include <getopt.h>

int main(int argc, char* argv[])
{
    int c = 0;
    int option_index = 0;
    int flag = -1;
    
    struct option long_options[] =
    {
        { "test",    required_argument, 0, 't' },
        { "n",       required_argument, 0, 'n' }, 
        { 0,         0,                 0,  0  }
    };

    while( 1 )
    {  
        int c = getopt_long_only(argc, argv, "d:f", long_options, &option_index);
        
        if( c == -1 ) break;
        
        printf("c = %c, optopt = %c, optarg = %s\n", c, optopt, optarg);
    }

    if( optind < argc )
    {
        printf("parameters:\n");
        
        while (optind < argc)
        {
            printf("%s\n", argv[optind++]);
        }
    }

    return 0;
}
